package svc

import (
	"UserServer/api/internal/config"
	"UserServer/api/internal/middleware"
	"UserServer/rpc/userclient"
	"github.com/zeromicro/go-zero/rest"
	"github.com/zeromicro/go-zero/zrpc"
)

type ServiceContext struct {
	Config            config.Config
	userclient.User   // 加入user rpc的服务操作函数
	LoginVerification rest.Middleware
}

func NewServiceContext(c config.Config) *ServiceContext {
	return &ServiceContext{
		Config:            c,
		User:              userclient.NewUser(zrpc.MustNewClient(c.UserRpc)), // 创建实例，这边相当于是服务端
		LoginVerification: middleware.NewLoginVerificationMiddleware().Handle,
	}
}
